import { Common } from '../../utils/common.js';
var common = new Common();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: false,
    route_list: '',
    delete_tour_name: "",
    id: "",
    show_action_sheet: false,
    copy:true,
    actions: [{
        name: '设为未完成将删除已上传的信息',
        className: 'title',
        disabled: true
      },
      {
        id: 1,
        name: '删除',
        className: 'choose_delete'
      },
      {
        id: 3,
        name: "",
        className: 'choose3'
      },
      {
        id: 2,
        name: '取消',
        className: 'choose_cancel'
      },
    ],
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    //获取所有行程安排
    this.GetAllScheduling();
  },

  copy_luggest: function() {
    var route_list = this.data.route_list;
    
    if (this.data.copy) {
      var data = { id: route_list[0].id}
      route_list[0].user_id = '-1';
      route_list.push(route_list[0])
      var datas = {
        data:data,
        type:'post',
        url:'scheduling/refer_add',
      }
      common.DataToData(datas,data=>{
        this.setData({
          route_list: route_list,
          copy: false
        })
      })
    }else{
      wx.showToast({
        title: '你已经复制过了',
        icon: 'none',
      })
    }
  },

  //所有的行程安排
  GetAllScheduling: function() {
    var that = this;
    var datas = {
      url:'scheduling/all',
      type:'post'
    }
    common.ToCallBack(datas,data => {
      that.setData({
        route_list: data,
      })
    })
  },

  //添加具体行程
  edit: function(e) {
    wx.navigateTo({
      url: '../route_list/list?info=' + JSON.stringify(this.data.route_list[e.currentTarget.dataset.id]),
    })
  },

  //开启新行程
  new_route: function() {
    wx.navigateTo({
      url: '../new_route/edit',
    })
  }
})